#ifndef CLIENT_H
#define CLIENT_H

#include <QtGui>
#include <QtNetwork>
#include <QIcon>

#include "Client.h"
#include "MonBoutonPush.h"
#include "Proto.h"
#include "MaSocketClient.h"
#include "FenPrincipale.h"
#include "SettingsListeProfils.h"

class MaSocketClient;
class FenPrincipale;

class Client : public QWidget
{
    Q_OBJECT

public:
    Client(FenPrincipale *fenetrePrincipale);
    void demandeConnexion();
    void demandeConnexionPass();
    void envoyerMessage(const QString &message = "");

private:
    // settingsListeProfils
    SettingsListeProfils *settingsListeProfils;

    // gestion du reseau.
    QTcpSocket *socket;
    MaSocketClient *maSocketClient;

    // communication interne avec le programme.
    FenPrincipale *fenetrePrincipale;

    QVBoxLayout *layout;

    QLabel *etat;
    QTextEdit *zoneText;
    // mode déconecté.
    QWidget *widgetDeconnecte;
    QGridLayout *layoutDeconnecte;
    MonBoutonPush *monBoutonPushManuel;
    MonBoutonPush *monBoutonPushProfil;
    // manuel
    QWidget *widgetDeconnecteManuel;
    QFormLayout *layoutDeconnecteManuel;
    QLineEdit *ip;
    QLineEdit *port;
    QLineEdit *pass;
    QLineEdit *nick;
    QWidget *widgetAjoutProfil;
    QLayout *ajoutProfilLayout;
    QLineEdit *nomProfil;
    MonBoutonPush *monBoutonPushAjoutProfil;
    // profil
    QWidget *widgetDeconnecteProfil;
    QVBoxLayout *layoutDeconnecteProfil;
    QLabel *labelListeProfils;
    QTreeView *listeProfils;

    MonBoutonPush *monBoutonPushCo;

    // mode connecté.
    QWidget *widgetConnecte;
    QVBoxLayout *layoutConnecte;
    QTreeView *listeClients;
    MonBoutonPush *monBoutonPushDeco;

signals:
    void sig_connecte();
    void sig_deconnecte();

public slots:
    void on_monBoutonPushAjoutProfil_clicked();
    void on_monBoutonPushCo_clicked();
    void on_monBoutonPushDeco_clicked();
    void on_monBoutonPushManuel_clicked();
    void on_monBoutonPushProfil_clicked();
    void connexionParProfil(const QString &ip, const QString &port, const QString &nick, const QString &pass = "");
    void connecte();
    void deconnecte();
    void erreurSocket(QAbstractSocket::SocketError erreur);
    void connexionAcceptee();
    void connexionRefusee(QString message);
    void recevoirEnvoyerATous(QString message);
};

#endif // CLIENT_H
